<div class="example">
  <h3>Checkboxes</h3>
  <form id='checkboxes'>
    <input type="checkbox"> checkbox 1</br>
    <input type="checkbox" checked> checkbox 2
  </form>
</div>
<script>
var form = document.getElementById('checkboxes');
var checkboxes = form.getElementsByTagName('input');
for (var i=0, len=checkboxes.length; i<len; i++) {
    checkboxes[i].onclick = function() {
      this.checked ? this.setAttribute("checked", "") : this.removeAttribute("checked");
    }
}
</script>
